package com.lineage.data.npc.event;

import com.lineage.data.event.StatusSet;
import com.lineage.data.executor.NpcExecutor;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.skill.L1SkillUse;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.S_SkillHaste;
import com.lineage.server.serverpackets.S_SkillSound;
import com.lineage.server.serverpackets.ServerBasePacket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Npc_Status extends NpcExecutor {
  private static final Log _log = LogFactory.getLog(Npc_Status.class);
  
  public static NpcExecutor get() {
    return new Npc_Status();
  }
  
  public int type() {
    return 3;
  }
  
  public void talk(L1PcInstance pc, L1NpcInstance npc) {
    int npcid = npc.getNpcId();
    if (npcid == 81242 && pc.getLevel() < 13) {
      pc.sendPackets((ServerBasePacket)new S_SkillHaste(pc.getId(), 1, 1600));
      pc.sendPackets((ServerBasePacket)new S_SkillSound(pc.getId(), 755));
      pc.setMoveSpeed(1);
      pc.setSkillEffect(1001, 1600000);
      pc.setCurrentHp(pc.getMaxHp());
      if (pc.getLevel() < 13)
        pc.setCurrentMp(pc.getMaxMp()); 
      pc.sendPackets((ServerBasePacket)new S_SkillSound(pc.getId(), 830));
    } else {
      action(pc, npc, "addStatus", 0L);
    } 
  }
  
  public void action(L1PcInstance pc, L1NpcInstance npc, String cmd, long amount) {
    if (cmd.equalsIgnoreCase("addStatus")) {
      int Money = ((Integer)StatusSet.SKILLLIST.get(0)).intValue();
      int time = ((Integer)StatusSet.SKILLLIST.get(2)).intValue();
      if (pc.getInventory().checkItem(Money, ((Integer)StatusSet.SKILLLIST.get(1)).intValue())) {
        pc.getInventory().consumeItem(Money, ((Integer)StatusSet.SKILLLIST.get(1)).intValue());
        L1SkillUse l1skilluse = new L1SkillUse();
        for (int i = 3; i < StatusSet.SKILLLIST.size(); i++)
          l1skilluse.handleCommands(pc, ((Integer)StatusSet.SKILLLIST.get(i)).intValue(), pc.getId(), pc.getX(), pc.getY(), time, 4); 
      } else {
        pc.sendPackets((ServerBasePacket)new S_ServerMessage("\\aG老板吉祥，没有" + StatusSet.SKILLLIST.get(1) + "是无法拥有祝福的!"));
      } 
    } 
  }
}
